package main

import (
	"context"
	"fmt"
	"newtomicroc/rpcconn/pb"
	"newtomicroc/rpcconn/pb/grpc-go"
)

func main() {
	//1 用grpc连接服务
	conn, err := grpc.Dial("127.0.0.1:8800", grpc.WithInsecure()) //连接安全传输
	if err != nil {
		fmt.Println("grpc.Dial 失败：", err)
		return
	}
	defer conn.Close()

	//2 初始化grpc客户端
	grpcClient := pb.NewSayNameClient(conn)

	//创建并初始化teacher 对象
	var teacher pb.Teacher
	teacher.Name = "zz"
	teacher.Age = 32
	//3 远程调用服务
	t, err := grpcClient.SayHello(context.TODO(), new(pb.Teacher), &teacher) //context.TODO()空对象

	fmt.Println(t, err)
}
